package cn.com.capinfo.ea.example.demo.service



import cn.com.capinfo.ea.example.demo.domain.Book
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.core.annotation.Order
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.junit4.SpringRunner
/**
 * Generate by CapinfoTools EA-3.7.0 on 2020-07-27.
 */

@ComponentScan(basePackages=["cn.com.capinfo"])
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
@EnableAutoConfiguration
class BookServiceTests {
    @Autowired BookService bookService
    @Test
    public void testCRUD(){
        long count=bookService.count({})
        Book book = bookService.create([:])
         //@todo 完善属性赋值
        //book.name='xxx'
        bookService.save(book)
        assert bookService.count({})==(count+1)
        book=bookService.get(book.id)
         //@todo 修改属性值
        //book.name='xxx'
        bookService.save(book)
        //@todo 判断值是否修改
        //assert bookService.get(book.id).name='xxx'
        bookService.delete(book)
        assert bookService.count({})==count
    }
}
